<?php


namespace App\Base;

use App\Utility\Jwt;

/**
 * 用户登录认证
 * Class Auth
 * @package App\Base
 */
class AuthManager
{
    private static $payload;

    /**
     * 获取Jwt中的自定义数据
     * @return mixed
     */
    public static function getPayload()
    {
        return self::$payload;
    }

    public static function auth(): bool
    {
        $token = getHeaderParam('JWTTOKEN');
        self::$payload = Jwt::init()->verifyToken($token);

        return !(self::$payload === false);
    }
}